package com.skymobi.common;

import stc.skymobi.util.JVMUtil;

import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.Arrays;

public class AppRunner {

    public static void main(String[] args) throws Exception {
        if (args.length == 0) {
            System.err.println("please specify the class to start in args");
            System.exit(-1);
        }
        String[] extjars = JVMUtil.addAllJarsToClassPath(System.getProperty("user.dir") + "/lib");
        for (String jarname : extjars) {
            System.out.println("add path [" + jarname + "]");
        }
        Class mainClass = Class.forName(args[0]);
        Method mainMethod = mainClass.getMethod("main", Array.newInstance(String.class, 0).getClass());
        mainMethod.invoke(null, new Object[]{Arrays.copyOfRange(args, 1, args.length)});
    }
}
